//
//  OrderFooterTotalString.m
//  StandardizedProduct
//
//  Created by 宁宁 on 16/7/5.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "OrderFooterTotalString.h"

@implementation OrderFooterTotalString

+ (NSAttributedString *)AttributedStringWithNum:(NSNumber *)num andTotal:(NSNumber *)total andFreight:(NSString *)freight{
    
    NSString *number = [NSString stringWithFormat:@"%@", num];
    
    NSMutableString *count = [NSMutableString stringWithFormat:@"%@", total];
    //查找.
    NSRange range = [count rangeOfString:@"."];
    if (range.location == NSNotFound) {
        [count appendString:@".00"];
    }else if (range.length == 1){
        [count appendString:@"0"];
    }else if (range.length > 2){
        count = [NSMutableString stringWithFormat:@"%.2f", [total floatValue]];
    }
    
    NSString *footerString = [NSString stringWithFormat:@"共%@件商品  合计:¥%@(含运费 ¥%@)", number, count, freight];
    
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc] initWithString:footerString];
    
    [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:NSMakeRange(0, footerString.length)];
    
    //价格
    //修改字体大小
    [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0] range:NSMakeRange(10 + number.length, count.length - 3)];
    
    return AttributedStr;
}

@end
